import { createApp } from "vue";
import "./style.css";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";

// 在应用启动时从 LocalStorage 加载状态
if (localStorage.getItem("isLoggedIn")) {
  store.commit(
    "setLoginStatus",
    JSON.parse(localStorage.getItem("isLoggedIn")!)
  );
}
if (localStorage.getItem("isLocked")) {
  store.commit(
    "setLockStatus",
    JSON.parse(localStorage.getItem("isLocked")!)
  );
}
const app = createApp(App);
app.use(ElementPlus);

// 注册其他组件
for (const [name, comp] of Object.entries(ElementPlusIconsVue)) {
  app.component(name, comp);
}

app.use(store);
app.use(router);
app.mount("#app");